package com.neizhijiekou;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class PredicateTest {

    public static void main(String[] args) {
//        //

//
//        List<String> newcitys = new ArrayList<>();
//        for (String string : strings) {
//            if (string.contains("州")){
//                newcitys.add(string);
//            }
//        }
//
//        System.out.println(newcitys);
        String[] citys = {"郑州","广州1","杭州","驻马店","南京","北京"};
        List<String> strings = Arrays.asList(citys);

        PredicateTest predicateTest = new PredicateTest();
        List<String> city = predicateTest.predicateCity(strings, s -> s.contains("州"), s -> s.length()==3);
        System.out.println(city);
    }


    public List<String> predicateCity(List<String> citys,Predicate<String> predicate,Predicate<String> predicate2){
        List<String> newcitys = new ArrayList<>();
        for (String string : citys) {
            // 城市 符不符合 断线
            if (predicate.and(predicate2).test(string)){
                newcitys.add(string);
            }
        }
        return newcitys;

    }


}
